home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 76 / XENIATGM66.iso / Indiana Jones / Indiana Jones.exe / RESOURCE / PREVIEW.GOB / cog_gen_doordouble.cog < prev    next >
Text File  |  1999-11-15  |  3KB  |  120 lines

  1. # Jones 3D Cog Script
  2. #
  3. # gen_DoorDouble.cog
  4. #
  5. # Door Script
  6. #
  7. # [SXC]
  8. #
  9. # (C) 1997 LucasArts Entertainment Co. All Rights Reserved
  10. # ========================================================================================
  11.  
  12. symbols
  13.     message    startup        
  14.     message    activate    
  15.     message    arrived        
  16.     message    blocked        
  17.  
  18.     thing        door0        linkid=0
  19.     thing        door1        linkid=1
  20.  
  21.     flex        movespeed=8.0
  22.     flex        sleeptime=2.0
  23.  
  24.     float        lightValueR=0.5
  25.     float        lightValueG=0.5
  26.     float        lightValueB=0.5
  27.  
  28.     vector    vecLightValue        local
  29.  
  30.     sector    doorsector    local
  31.     int        numdoors        local
  32.     int        doorstatus    local
  33.     int        movestatus    local
  34.     sector    doorsector2    local
  35.  
  36. # subroutines
  37. flex    checkstatus=0.0        local
  38. flex    open_doors=0.0        local
  39. flex    close_doors=0.0        local
  40. end
  41.  
  42. code
  43.  
  44. # .................................................................................................
  45.  
  46. startup:
  47.     if (door0 >= 0)    numdoors = numdoors + 1;
  48.     if (door1 >= 0) numdoors = numdoors + 1;
  49.  
  50.     doorsector = getthingsector(door0);
  51.     doorsector2 = getthingsector(door1);
  52.  
  53.     sectoradjoins(doorsector, 0);
  54.     sectoradjoins(doorsector2, 0);
  55.  
  56.     // add light to door sector
  57.     vecLightValue = VectorSet(lightValueR, lightValueG, lightValueB);
  58.     sectorlight(doorsector, vecLightValue, 0.0);
  59.     sectorlight(doorsector2, vecLightValue, 0.0);
  60.     return;
  61.  
  62. # .................................................................................................
  63.  
  64. activated:
  65.     call checkstatus;
  66.     if (movestatus) return;
  67.     if (doorstatus == 0) {                    // all pieces are at frame 0
  68.         sectoradjoins(doorsector, 1);
  69.         sectoradjoins(doorsector2, 1);
  70.         call open_doors;
  71.     }
  72.     return;
  73.  
  74. # .................................................................................................
  75.  
  76. arrived:
  77.     call checkstatus;
  78.     if (movestatus) return;
  79.     if (doorstatus == numdoors) {                // all pieces are at frame 1
  80.         sleep(sleeptime);
  81.         call close_doors;
  82.     } else if (doorstatus == 0) {                // all pieces are at frame 0
  83.         sectoradjoins(doorsector, 0);
  84.         sectoradjoins(doorsector2, 0);
  85.     }
  86.     return;
  87.  
  88. # .................................................................................................
  89.  
  90. blocked:
  91.     call open_doors;
  92.     return;
  93.  
  94. # .................................................................................................
  95.  
  96. open_doors:
  97.     movetoframe(door0, 1, movespeed);
  98.     if (door1 >= 0) movetoframe(door1, 1, movespeed);
  99.     return;
  100.  
  101. # .................................................................................................
  102.  
  103. close_doors:
  104.     movetoframe(door0, 0, movespeed);
  105.     if (door1 >= 0) movetoframe(door1, 0, movespeed);
  106.     return;
  107.  
  108. # .................................................................................................
  109.  
  110. checkstatus:
  111.     movestatus = ismoving(door0);
  112.     if (door1 >= 0) movestatus = movestatus + ismoving(door1);
  113.  
  114.     doorstatus = getcurframe(door0);
  115.     if (door1 >= 0) doorstatus = doorstatus + getcurframe(door1);
  116.     return;
  117.  
  118. end
  119.  
  120.